package com.test.project_test.test.configuration;

import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
 
/*@Slf4j
@Component
public class ApolloRefreshConfig {
    @Resource
    private AppConfig appConfig;
    @Resource
    private RefreshScope refreshScope;
    @Resource
    private ApplicationContext applicationContext;
 
    //value对应配置的namespace 
    //prefixes 为你的配置前缀，没有可不写
    //refreshScope.refresh的参数是自定义配置的BeanName
    @ApolloConfigChangeListener(value = {"profile", "application"}, interestedKeyPrefixes = "prefixes.")
    public void appConfigChange(ConfigChangeEvent changeEvent) {
        log.info("配置更新前|{}", appConfig);
        refreshScope.refresh("appConfig");
        log.info("配置更新后|{}", appConfig);
    }
 
    @ApolloConfigChangeListener(value = {"profile", "application"}, interestedKeyPrefixes = "logging.level.")
    public void loggingLevelChange(ConfigChangeEvent changeEvent) {
        applicationContext.publishEvent(new EnvironmentChangeEvent(changeEvent.changedKeys()));
        log.info("日志级别配置更新完成|{}", changeEvent.changedKeys());
    }
    }
    */


